using UnityEngine;

public class Story : MonoBehaviour
{
	public CampaignGame campaignGame;

	public Zombie startZombie;

	public Bus bus;

	public GameObject busZombies;

	private void Update()
	{
		if (campaignGame.storyState <= 0)
		{
			return;
		}
		campaignGame.player.xInput = 0f;
		campaignGame.player.yInput = 0f;
		if (campaignGame.storyState == 1)
		{
			base.transform.Find("Camera").GetComponent<SmoothFollow>().targetTransform = base.transform.Find("Story/Cam").transform;
			campaignGame.player.transform.position = new Vector2(-15f, -1.5f);
		}
		else if (campaignGame.storyState > 1 && campaignGame.player.transform.position.x < -11f)
		{
			campaignGame.player.xInput = 1f;
			campaignGame.player.yInput = 0.3f;
		}
		else if (campaignGame.storyState == 4)
		{
			campaignGame.player.xInput = 1f;
		}
		else if (startZombie.body.isDead && campaignGame.storyState < 3)
		{
			campaignGame.SetStoryState(3);
		}
		else if (campaignGame.storyState == 100)
		{
			Vector2 vector = new Vector2(campaignGame.player.transform.position.x + 15f, -1.7f);
			bus.transform.position = vector;
			busZombies.transform.position = vector;
			busZombies.SetActive(value: true);
			bus.gameObject.SetActive(value: true);
			campaignGame.SetStoryState(101);
		}
		else if (campaignGame.storyState == 101)
		{
			float num = Vector2.Distance(campaignGame.player.transform.position, bus.transform.position);
			float num2 = 5f;
			bus.rb.AddForce(Vector2.left * 40000f);
			if (num < num2)
			{
				campaignGame.SetStoryState(102);
			}
		}
		else if (campaignGame.storyState == 103)
		{
			campaignGame.player.transform.localScale = new Vector3(-1f, 1f, 1f);
			campaignGame.player.xInput = -1f;
			campaignGame.player.body.animator.SetFloat("xInput", 1f);
		}
		else if (campaignGame.storyState == 200)
		{
			campaignGame.player.transform.localScale = new Vector3(1f, 1f, 1f);
			campaignGame.player.transform.position = new Vector2(-2.5f, -1.5f);
			bus.transform.localScale = new Vector2(-1f, 1f);
			bus.transform.position = new Vector2(campaignGame.player.transform.position.x + 15f, bus.transform.position.y);
			campaignGame.SetStoryState(201);
		}
	}
}
